<?php
include 'functions.php';

$q=$_GET["q"];

$con = connect_db();
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

//mysql_select_db("ajfax_demo", $con);

$sql="SELECT cropname FROM CROP WHERE cropname REGEXP '^".$q."'";

$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
  {
  print $row['cropname'] . "<br />";
  }

mysql_close($con);

//some of this code was adapted from http://www.w3schools.com/php/php_ajax_database.asp
?> 